package main

import "fmt"

func quickSort(nums []int, left, right int) {
	if left >= right {
		return
	}
	val := nums[left]
	k := left
	for i := left + 1; i <= right; i ++ {
		if nums[i] < val {
			nums[k] = nums[i]
			nums[i] = nums[k + 1]
			k ++
		}
	}
	nums[k] = val
	fmt.Println(nums)
	quickSort(nums, left, k - 1)
	quickSort(nums, k + 1, right)
}

func main() {
	nums := []int{3,4,1,7,0,8, 23, -9, 89, -3}
	quickSort(nums, 0, len(nums) - 1)

	fmt.Println("--------------------------------------")
	fmt.Println(nums)
}
